#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int n, m;

int main() {
	cin >> n >> m;
	queue<int> q;
	for (int i = 1; i <= n; ++i) {
		q.push(i);
	}
	while (q.size() > 0) {
		for (int i = 1; i < m; ++i) {
			q.push(q.front());
			q.pop();
		}
		cout << q.front() << ' ';
		q.pop();
	}
	return 0;
}